package com.tingyuge.mapper;

import com.sun.org.apache.xpath.internal.operations.Or;
import com.tingyuge.entity.Order;
import com.tingyuge.entity.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface IOrderMapper {
    @Select("select * from orders")
    @Results({
            @Result(id=true,property = "id",column = "id"),
            @Result(property = "ordertime",column = "ordertime"),
            @Result(property = "total",column = "total"),
            @Result(property = "user",column = "uid",javaType = User.class,
                    one = @One(select ="com.tingyuge.mapper.IUserMapper.findUserById",fetchType = FetchType.LAZY))
    })
    List<Order> findAll();
    List<User> findByCondition(User user);
    /**
     * 多值查询
     */

    List<User>  findByIds(List<Integer> ids);
    //查询订单的同时还查询该订单的用户
    List<Order> findOrderAndUser();
    @Select("select * from orders where uid=#{uid}")
    List<Order> findByUid(int uid);
}
